/**
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package us.levk.remote.drmaa.server.xmlrpc;

import java.util.Map;
import java.util.UUID;

import org.apache.log4j.Logger;
import org.ggf.drmaa.DrmaaException;
import org.ggf.drmaa.JobInfo;

import us.levk.remote.drmaa.common.api.RemoteJobInfo;

/**
 * @author levk
 *
 */
public class JobInfoImpl implements RemoteJobInfo {
  private static final long serialVersionUID = 1L;

  @SuppressWarnings ("unused") private static final transient Logger LOG = Logger.getLogger (JobInfoImpl.class);

  /* (non-Javadoc)
   * @see us.levk.remote.drmaa.common.RemoteJobInfo#getJobId(java.util.UUID)
   */
  @Override public String getJobId (UUID info) throws DrmaaException {
    JobInfo i = Instances.INFOS.get (info);
    if (i == null) throw new DrmaaException ("Invalid JobInfo object") { private static final long serialVersionUID = 1L; };
    return i.getJobId ();
  }

  /* (non-Javadoc)
   * @see us.levk.remote.drmaa.common.RemoteJobInfo#getResourceUsage(java.util.UUID)
   */
  @Override public Map<?, ?> getResourceUsage (UUID info) throws DrmaaException {
    JobInfo i = Instances.INFOS.get (info);
    if (i == null) throw new DrmaaException ("Invalid JobInfo object") { private static final long serialVersionUID = 1L; };
    return i.getResourceUsage ();
  }

  /* (non-Javadoc)
   * @see us.levk.remote.drmaa.common.RemoteJobInfo#hasExited(java.util.UUID)
   */
  @Override public boolean hasExited (UUID info) throws DrmaaException {
    JobInfo i = Instances.INFOS.get (info);
    if (i == null) throw new DrmaaException ("Invalid JobInfo object") { private static final long serialVersionUID = 1L; };
    return i.hasExited ();
  }

  /* (non-Javadoc)
   * @see us.levk.remote.drmaa.common.RemoteJobInfo#getExitStatus(java.util.UUID)
   */
  @Override public int getExitStatus (UUID info) throws DrmaaException {
    JobInfo i = Instances.INFOS.get (info);
    if (i == null) throw new DrmaaException ("Invalid JobInfo object") { private static final long serialVersionUID = 1L; };
    return i.getExitStatus ();
  }

  /* (non-Javadoc)
   * @see us.levk.remote.drmaa.common.RemoteJobInfo#hasSignaled(java.util.UUID)
   */
  @Override public boolean hasSignaled (UUID info) throws DrmaaException {
    JobInfo i = Instances.INFOS.get (info);
    if (i == null) throw new DrmaaException ("Invalid JobInfo object") { private static final long serialVersionUID = 1L; };
    return i.hasSignaled ();
  }

  /* (non-Javadoc)
   * @see us.levk.remote.drmaa.common.RemoteJobInfo#getTerminatingSignal(java.util.UUID)
   */
  @Override public String getTerminatingSignal (UUID info) throws DrmaaException {
    JobInfo i = Instances.INFOS.get (info);
    if (i == null) throw new DrmaaException ("Invalid JobInfo object") { private static final long serialVersionUID = 1L; };
    return i.getTerminatingSignal ();
  }

  /* (non-Javadoc)
   * @see us.levk.remote.drmaa.common.RemoteJobInfo#hasCoreDump(java.util.UUID)
   */
  @Override public boolean hasCoreDump (UUID info) throws DrmaaException {
    JobInfo i = Instances.INFOS.get (info);
    if (i == null) throw new DrmaaException ("Invalid JobInfo object") { private static final long serialVersionUID = 1L; };
    return i.hasCoreDump ();
  }

  /* (non-Javadoc)
   * @see us.levk.remote.drmaa.common.RemoteJobInfo#wasAborted(java.util.UUID)
   */
  @Override public boolean wasAborted (UUID info) throws DrmaaException {
    JobInfo i = Instances.INFOS.get (info);
    if (i == null) throw new DrmaaException ("Invalid JobInfo object") { private static final long serialVersionUID = 1L; };
    return i.wasAborted ();
  }
}
